//
//  MeViewModel.swift
//  iPhone
//
//  Created by Toj on 5/15/23.
//

import UIKit

class MeViewModel: NSObject {
    
    private(set) lazy var classSections: [VCSectionModel] = []
}

extension MeViewModel {
    
    func setupSections(complete: @escaping ()->Void) {
        DispatchQueue.global(qos: .background).async {
            var sections = [VCSectionModel]()
            var sectionModel = VCSectionModel()
            
            sectionModel = self.setupUICellModels()
            sections.append(sectionModel)
            
            sectionModel = self.setupTestTopCellModels()
            sections.append(sectionModel)
            
            sectionModel = self.setupProductCellModels()
            sections.append(sectionModel)
            
            sectionModel = self.setupFuncCellModels()
            sections.append(sectionModel)
            
            DispatchQueue.main.async {
                self.classSections = sections
                complete()
            }
        }
    }
}

private extension MeViewModel {
    
    func setupSection() -> VCSectionModel {
        let section = VCSectionModel()
        section.headerSize = CGSize(width: .sr_width, height: 44)
        section.footerSize = .def_cipher
        return section
    }
}

private extension MeViewModel {
    
    func setupTestTopCellModels() -> VCSectionModel {
        var cellModels = [VCCellModel]()
        var cellModel = VCCellModel()
        
        cellModel = VCCellModel()
        cellModel.name = STOSRViewController.cm_objectName
        cellModel.des = "离屏渲染Demo"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STPlayerDetailController.cm_objectName
        cellModel.des = "播放详情页 Tab"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STOrderPushController.cm_objectName
        cellModel.des = "DVB VOD推送页面"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = TVOrderViewController.cm_objectName
        cellModel.des = "订单目录"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STAnimationViewController.cm_objectName
        cellModel.des = "动画"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STPlayerViewController.cm_objectName
        cellModel.des = "视频播放页"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STNativeCollectionViewController.cm_objectName
        cellModel.des = "admob 原生广告 Demo"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STBannerCollectionViewController.cm_objectName
        cellModel.des = "admob banner广告优化 Demo"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = SubscribeController.cm_objectName
        cellModel.des = "本地推送消息 Demo"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STOrientationController.cm_objectName
        cellModel.des = "屏幕方向 Demo"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = TimeViewController.cm_objectName
        cellModel.des = "时间 Demo"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STMutableCopyController.cm_objectName
        cellModel.des = "测试MutableCopy"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STTestProtocrolController.cm_objectName
        cellModel.des = "测试协议"
        cellModels.append(cellModel)
        
        let section = setupSection()
        section.title = "UI Demo"
        section.cellModels = cellModels
        
        return section
    }
    
    func setupUICellModels() -> VCSectionModel {
        var cellModels = [VCCellModel]()
        var cellModel = VCCellModel()
        
        cellModel = VCCellModel()
        cellModel.name = STAttributedStringController.cm_objectName
        cellModel.des = "富文本属性"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STCollectionViewController.cm_objectName
        cellModel.des = "CollectionView Demo"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STTableViewController.cm_objectName
        cellModel.des = "TableView Demo"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STTestStatusBarViewController.cm_objectName
        cellModel.des = "状态栏 Demo"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = ContentModeViewController.cm_objectName
        cellModel.des = "image content mode Demo"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STTestLabelController.cm_objectName
        cellModel.des = "Label Demo"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STTestParentController.cm_objectName
        cellModel.des = "Moda方式Demo"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STLineViewController.cm_objectName
        cellModel.des = "横线"
        cellModels.append(cellModel)
        
        let section = setupSection()
        section.title = "自定义UI Demo"
        section.cellModels = cellModels
        
        return section
    }
    
    func setupFuncCellModels() -> VCSectionModel {
        var cellModels = [VCCellModel]()
        var cellModel = VCCellModel()
        
        cellModel = VCCellModel()
        cellModel.name = InStationAlertController.cm_objectName
        cellModel.des = "站内弹窗"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = UITextFieldController.cm_objectName
        cellModel.des = "自定义文本框"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = UIFlowLightViewController.cm_objectName
        cellModel.des = "流光效果"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STLanguageController.cm_objectName
        cellModel.des = "语言包"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STRefreshViewController.cm_objectName
        cellModel.des = "MJ刷新测试"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = KFDownloadViewController.cm_objectName
        cellModel.des = "Kingfisher下载图片"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = NumberViewController.cm_objectName
        cellModel.des = "数字变化"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STMessageComposeViewController.cm_objectName
        cellModel.des = "分享短信弹出"
        cellModels.append(cellModel)
        
        let section = setupSection()
        section.title = "功能UI Demo"
        section.cellModels = cellModels
        
        return section
    }
    
    func setupProductCellModels() -> VCSectionModel {
        var cellModels = [VCCellModel]()
        var cellModel = VCCellModel()
        
        cellModel = VCCellModel()
        cellModel.name = STSettingController.cm_objectName
        cellModel.des = "设置"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = TVStatementViewController.cm_objectName
        cellModel.des = "账单目录"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = STProductDetailController.cm_objectName
        cellModel.des = "商品页"
        cellModels.append(cellModel)
        
        cellModel = VCCellModel()
        cellModel.name = TVLinkingCardViewController.cm_objectName
        cellModel.des = "绑卡页"
        cellModels.append(cellModel)
        
        let section = setupSection()
        section.title = "项目UI Demo"
        section.cellModels = cellModels
        
        return section
    }
}
